using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX.DirectDraw;
using Microsoft.DirectX.DirectInput;
using TowerDefense_Dx.GameLogic;

namespace TowerDefense_Dx.Core
{
    public delegate void Action();
    public class DxButton:DxSprite
    {
        public enum BUTTON_STATE
        {
            NORMAL = 0,
            HOLD = 1,
            CLICKED = 2
          
        }
        protected BUTTON_STATE _state;

        public BUTTON_STATE State
        {
            get { return _state; }
            set { _state = value; }
        }
        protected RectangleF _bounding;

        public RectangleF Bounding
        {
            get { return _bounding; }
            set { _bounding = value; }
        }
        protected byte[] _buttons;
        protected Action _onMouseDown = null;
        public Action OnMouseDown
        {
            set { _onMouseDown = value; }
        }
        protected Action _onMouseUp = null;
        public Action OnMouseUp
        {
            set { _onMouseUp = value ; }
        }
        protected Action _onMouseDrag = null;
        public Action OnMouseDrag
        {
            set { _onMouseDrag = value; }
        }
        public DxSprite sprite;

        public DxButton(string imagePath, Microsoft.DirectX.DirectDraw.Device graphicDevice, int frameWidth, int frameHeight, PointF position)
            : base(imagePath, graphicDevice, frameWidth, frameHeight)
        {
            _position.X = position.X;
            _position.Y = position.Y;
            _state = BUTTON_STATE.NORMAL;
            _bounding = new RectangleF(_position.X, _position.Y, _frameWidth, _frameHeight);

        }
        public virtual void Update(MouseState state)
        {           
        }        
        public void DrawFast(Surface destSurface, DrawFastFlags flags)
        {
            base.DrawFast((int)_position.X,(int) _position.Y, (int)_state + 1, destSurface, flags);            
        }        
    }
}
